package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsComplaint;
import com.yidu.logisticssystem.dao.LogisticsComplaintDao;
import com.yidu.logisticssystem.service.LogisticsComplaintService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 投诉(LogisticsComplaint)表服务实现类
 *
 * @author zp
 * @since 2021-03-11 15:11:16
 */
@Service("logisticsComplaintService")
public class LogisticsComplaintServiceImpl implements LogisticsComplaintService {
    @Resource
    private LogisticsComplaintDao logisticsComplaintDao;

    /**
     * 通过ID查询单条数据
     *
     * @param complaintId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsComplaint queryById(Integer complaintId) {
        return this.logisticsComplaintDao.queryById(complaintId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsComplaint> queryAllByLimit(int offset, int limit) {
        return this.logisticsComplaintDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsComplaint 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsComplaint insert(LogisticsComplaint logisticsComplaint) {
        this.logisticsComplaintDao.insert(logisticsComplaint);
        return logisticsComplaint;
    }

    /**
     * 修改数据
     *
     * @param logisticsComplaint 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsComplaint update(LogisticsComplaint logisticsComplaint) {
        this.logisticsComplaintDao.update(logisticsComplaint);
        return this.queryById(logisticsComplaint.getComplaintId());
    }

    /**
     * 通过主键删除数据
     *
     * @param complaintId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer complaintId) {
        return this.logisticsComplaintDao.deleteById(complaintId) > 0;
    }
}
